
package org.spp.utilities.comparators; 

import java.util.Comparator;

import org.spp.voronoi.Centroid;

/**
 * ScoreComparator.java
 * @author Ilio Catallo, Eleonora Ciceri
 * @version 1.0
 * @see Point
 * 
 * Description: the class compares two centroids and orders them in a decreasing order
 *              with respect to the score
 * 
 * Date: Jul 15, 2011
 */
public class ScoreComparator implements Comparator<Centroid>{
    
    /**
     * Method that orders centroids in a decreasing order with respect to the score.
     * A value of 0 indicates that the two centroids have the same score; a value
     * of -1 indicates that the first centroid's score is bigger than the second 
     * centroid's one; a value of 1 indicates that the first centroid's score is smaller 
     * than the second centroid's one
     * @return compareResult
     */
    public int compare(Centroid c1, Centroid c2){
        
        if (c1.getScore() > c2.getScore())
            return -1;
        
        if (c1.getScore() < c2.getScore())
            return 1;
        
        return 0;
    }    
    
}
